package com.ytjj.quartz.utils;

/**
 *
 * @version 1.0
 * 
 */
import com.tencent.ads.ApiContextConfig;
import com.tencent.ads.TencentAds;
import com.tencent.ads.exception.TencentAdsResponseException;
import com.tencent.ads.exception.TencentAdsSDKException;
import com.tencent.ads.model.AmUserActionSetType;
import com.tencent.ads.model.UserActionSetsAddRequest;
import com.tencent.ads.model.UserActionSetsAddResponseData;

public class AddUserActionSets {
//    /** YOUR ACCESS TOKEN */
//    public String ACCESS_TOKEN = "39ccff7d4207d6e21cfabb82abb9d577";

    /** YOUR ACCESS TOKEN */
    public String ACCESS_TOKEN = "9ce6f99eacd17cf11a8fc06ab62d7bd1";

    /** TencentAds */
    public TencentAds tencentAds;

//    public Long accountId = 18006086L;
    public Long accountId = 18004858L;
    public UserActionSetsAddRequest data = new UserActionSetsAddRequest();
    public String name = "小程序激活";
    public AmUserActionSetType type = AmUserActionSetType.WECHAT;

    public void init() {
        this.tencentAds = TencentAds.getInstance();
        this.tencentAds.init(
                new ApiContextConfig().accessToken(ACCESS_TOKEN).isDebug(true)); // debug==true 会打印请求详细信息
        this.tencentAds.useProduction(); // 默认使用沙箱环境，如果要请求线上，这里需要设为线上环境
        this.buildParams();
    }

    public void buildParams() {
        data.setAccountId(accountId);

        data.setName(name);

        data.setType(type);
//        data.setMobileAppId(1109716893L);
        data.setWechatAppId("wxc2d6e3dff52c8c87");
        data.setDescription("小程序激活");
    }

    public UserActionSetsAddResponseData addUserActionSets() throws Exception {
        UserActionSetsAddResponseData response = tencentAds.userActionSets().userActionSetsAdd(data);
        return response;
    }

    public static void main(String[] args) {
        try {
            AddUserActionSets addUserActionSets = new AddUserActionSets();
            addUserActionSets.init();
            UserActionSetsAddResponseData response = addUserActionSets.addUserActionSets();
        } catch (TencentAdsResponseException e) {
            e.printStackTrace();
        } catch (TencentAdsSDKException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

